/**
 * Created by 白雨浓 on 2018/1/16 11:38.
 */
import {types} from './types';

export default {
    entity(self, table, fields){
        let attr = '';
        for (const field of fields) {
            if (field.COLUMN_NAME === 'id') {
                attr += `\tprivate int id;\n`;
            } else if (field.COLUMN_NAME === 'state') {
                attr += `\tprivate Boolean state;\n`;
            } else {
                attr += `\tprivate ${types[field.DATA_TYPE]} ${self.$str.toCamel(field.COLUMN_NAME)};\n`;
            }
        }

        let clsName = self.$str.toCamel(table);
        clsName = clsName.substring(0, 1).toUpperCase() + clsName.substring(1);

        return `package ${self.config.packageName}.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * ${self.config.packageName}.entity
 *
 * @author 白雨浓
 * date: ${self.$date.format(new Date(), 'yyyy/MM/dd hh:mm')}
 * content: 实体
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ${clsName}Entity implements Serializable {

    ${attr}
}
        `;
    },
};
